# 4-12

x <- c(127.3, 130.0, 132.7, 129.4, 135.0,
       137.1, 141.1, 142.8, 145.5, 145.3,
       148.3, 146.4, 150.2, 153.1, 157.3,
       160.7, 164.2, 165.6, 168.7, 172.0)

y <- c(20.96, 21.40, 21.96, 21.52, 22.39,
       22.76, 22.48, 23.66, 24.10, 24.01,
       24.54, 24.28, 25.00, 25.64, 26.46,
       26.98, 27.52, 27.78, 28.24, 28.78)

model <- lm(y~x)
summary(model)

library(ggplot2)

data1 <- data.frame(y = y, residual = model$residuals)

p<-ggplot(data1, aes(x=y, y=residual)) +
   geom_point()+
   ylim(-1, 1)+
   theme_classic()

ggsave('resplot_4_12.png', p, width = 5, height = 5)
p